package leetcode;

/**
 * @author:xufengxiang
 * @date 2023-03-13 20:00
 */
public class Code11 {

    public static int maxArea(int[] height) {
        int length = height.length;
        int left = 0;
        int right = length-1;

        int capacity = 0;
        while(left < right){
            int curCapacity = (right - left) * Math.min(height[left], height[right]);
            if(capacity < curCapacity){
                capacity = curCapacity;
            }
            if(height[left] <= height[right]){
                left ++;
            }else{
                right--;
            }
        }
        return capacity;
    }

    public static void main(String[] args) {
        int capacity = maxArea(new int[]{1, 8, 6, 2, 5, 4, 8, 3, 7});
        System.out.println(capacity);
    }
}
